package com.neusoft.bizcore.webauth.secret;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import com.neusoft.bizcore.mom.messaging.ProducerService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class SendingLogMessage {

    @Autowired
    private Environment environment;

    @Autowired
    private ProducerService producerService; //kafka 推送消息

    public void sendMsgToLogServer(final String logBeanJson) {
        final String kafka = this.environment.getProperty("spring.kafka.bootstrap-servers");
        SendingLogMessage.log.info("kakfa地址： " + kafka);

        if (StringUtils.isNotEmpty(kafka)) {
            final String topic = this.environment.getProperty("support.log.kafka-topic");
            SendingLogMessage.log.info("topic名称： " + topic);

            this.producerService.send(topic, logBeanJson);
        }
        SendingLogMessage.log.info("发送的消息内容是： " + logBeanJson);
    }

}
